package com.course.business.controller.admin;

import com.course.server.domain.Course;
import com.course.server.dto.*;
import com.course.server.service.CourseService;
import com.course.server.util.ValidatorUtil;
import org.apache.http.HttpResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpRequest;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author zht
 * @create 2021-09-05 15:58
 */
@RestController
@RequestMapping("/admin/course")
public class CourseController {

    public static final String BUSINESS_NAME =  "课程";
private static final Logger LOG = LoggerFactory.getLogger(CourseController.class);
    @Resource
    private CourseService courseService;

    /**
     * 列表查询
     */
    @RequestMapping("/list")
    public ResponseDto list(PageDto pageDto){
        ResponseDto responseDto = new ResponseDto();
        courseService.list(pageDto);
        responseDto.setContent(pageDto);
        return responseDto;
    }
    /**
     * 保存，id有值时更新，无值时新增
     */
    @RequestMapping("/save")
    @ResponseBody
    public ResponseDto save( CourseDto courseDto){
        System.out.println(courseDto);


        // 保存校验
//            ValidatorUtil.require(courseDto.getName(), "名称");
//            ValidatorUtil.length(courseDto.getName(), "名称", 1, 50);
//            ValidatorUtil.length(courseDto.getSummary(), "概述", 1, 2000);
//            ValidatorUtil.length(courseDto.getImage(), "封面", 1, 100);
//
//
//        ResponseDto responseDto = new ResponseDto();
//        courseService.save(courseDto);
//        responseDto.setContent(courseDto);
//        return responseDto;
        return null;


    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public ResponseDto delete(String id){
        System.out.println(id);
        ResponseDto responseDto = new ResponseDto();
        courseService.delete(id);
        return responseDto;
    }

}
